<template>
	<view class="content">
		<view class="body">
			<view class="body_title" @click="to_yugao()">
				<!-- <image src="../../static/img/common/shuangcengyuandian.png" mode=""></image> -->
				<text>直播预告</text>
				{{info.next_time||""}}
			</view>

			<view class="body_pic">
				<u-swiper :list="list1" height="314"></u-swiper>
			</view>

			<view class="btn">
				<view class="btn_list">
					<view class="btn_list_left" @click="to_live()">
						视频号正在直播
					</view>
					<!-- <image src="../../static/img/index/youjiantou.png" mode=""></image> -->
				</view>

				<view class="btn_list">
					<view class="btn_list_left" @click="to_sph_home()">
						进入视频号主页
					</view>
					<!-- <image src="../../static/img/index/youjiantou.png" mode=""></image> -->
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				list1: [],
				images: [],
				shipinhaoid: "",
				zhiboid: "",
				info: {
					current_url: 'sph3CJXFMtdcak3',//视频号id
				},
			}
		},
		onLoad() {

		},
		onShow() {
			// this.query_live_info()
		},
		methods: {
			//查询视频号信息
			query_live_info() {
				let params = {
					user_id: uni.getStorageSync('user_info').user_id,
					token: uni.getStorageSync('user_info').token
				}
				this.$http.getJson('index_shipinhao', params, "POST").then(res => {
					console.log(JSON.stringify(res))
					this.list1 = res.data.images.split(",")
					console.log(this.images)
					this.info = res.data
				})
			},
			
			// 视频号预告
			to_yugao() {
				wx.openChannelsActivity({
					finderUserName: this.info.main_url,
					feedId: 'export/UzFfAgtgekIEAQAAAAAAh3My0K4xJgAAAAstQy6ubaLX4KHWvLEZgBPE14EMbRkwbb-GzNPgMJp2A4whmfr8YBm5icxffYzk',
					success(res) {
						console.log(res)
					}
				})
			},
			
			//视频号直播
			to_live() {
				// 注意需要在真机调试查看sph3CJXFMtdcak3
				wx.getChannelsLiveInfo({
					finderUserName: this.info.current_url,
					startTime: 0,
					success(res) {
						console.log(JSON.stringify(res))
						if (res.status == 2) {
							wx.openChannelsLive({
								finderUserName: this.info.current_url,
								feedId: res.feedId,
								nonceId: res.nonceId,
								success(res) {
									console.log(JSON.stringify(res))
								},
								fail(res) {
									console.log(JSON.stringify(res))
								}
							})
						} else {
							uni.showToast({
								title: "直播未开始",
								icon: "none"
							})
						}

					},
					fail(res) {
						console.log(JSON.stringify(res))
					}
				})
			},
			
			
			// 视频号首页
			to_sph_home() {
				wx.openChannelsUserProfile({
					finderUserName: this.info.current_url,
					success(res) {
						console.log(res)
					},
					fail(res) {
						console.log(JSON.stringify(res))
					}
				})
			},

		}
	}
</script>

<style lang="scss">
	.content {
		min-height: 100vh;
		background: #F5F7FB;
		padding-bottom: 0;
		overflow: hidden;
	}

	.body {
		padding: 38rpx 30rpx;

		.body_title {
			display: flex;
			align-items: center;
			font-size: 26rpx;
			font-family: PingFang SC-Medium, PingFang SC;
			font-weight: 500;
			color: #E71F19;

			image {
				width: 42rpx;
				height: 42rpx;
			}

			text {
				margin: 0 28rpx;
				font-size: 34rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #E71F19;
			}

		}

		.body_pic {
			margin-top: 24rpx;
		}
	}


	.btn {
		margin-top: 30rpx;

		.btn_list {
			width: 688rpx;
			height: 100rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 0 14rpx;

			.btn_list_left {
				font-size: 34rpx;
				font-family: PingFang SC-Bold, PingFang SC;
				font-weight: bold;
				color: #333333;
				display: flex;
				align-items: center;
			}

			image {
				width: 20rpx;
				height: 30rpx;
			}
		}
	}
</style>